package com.usian.controller;

import com.usian.feign.SearchItemFeign;
import com.usian.pojo.SearchItem2;
import com.usian.utils.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/frontend/searchItem")
public class SearchItemWebController {
    @Resource
    private SearchItemFeign searchItemFeign;
    //导入商品数据到索引库
    @RequestMapping("/importAll")
    public Result importAll(){
        boolean b=searchItemFeign.importAll();
        if (b){
            return Result.ok();
        }else {
            return Result.error("导入商品数据到索引库失败");
        }
    }
    //商品搜索
    @RequestMapping("/list")
    public List<SearchItem2> selectByQ(String q, @RequestParam(defaultValue = "1")
            Long page, @RequestParam(defaultValue = "20") Integer pageSize){
        return searchItemFeign.selectByq(q,page,pageSize);
    }
}
